package com.softstao.guoyu.mvp.presenter;

import android.widget.ProgressBar;

import com.softstao.guoyu.mvp.interactor.UploadInteractor;
import com.softstao.guoyu.mvp.viewer.BaseViewer;
import com.softstao.guoyu.mvp.viewer.UploadTargetViewer;
import com.softstao.guoyu.mvp.viewer.UploadViewer;

import java.io.File;

/**
 * Created by xuhon on 2016/9/5.
 */
public class UploadPresenter extends BasePresenter<BaseViewer,UploadInteractor> {

    public void upload(File file , ProgressBar progressBar){
        interactor.uploadFile(progressBar,file,o ->
            ((UploadViewer)viewer).uploadResult((String) o)
        );
    }

    public void uploadForTarget(String tag,File file,ProgressBar progressBar){
        interactor.uploadFileForTarget(progressBar,tag,file,o -> {
            String[] result = ((String)o).split("`");
            ((UploadTargetViewer)viewer).uploadResult(result[0],result[1]);
        });
    }
}
